using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class medical_plan_drugMap : EntityTypeConfiguration<medical_plan_drug>
    {
        public medical_plan_drugMap()
        {
            // Primary Key
            this.HasKey(t => t.medical_plan_drug_id);

            // Properties
            this.Property(t => t.dosage)
                .HasMaxLength(200);

            this.Property(t => t.usage)
                .HasMaxLength(200);

            this.Property(t => t.note)
                .HasMaxLength(200);

            this.Property(t => t.indication)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("medical_plan_drug");
            this.Property(t => t.medical_plan_drug_id).HasColumnName("medical_plan_drug_id");
            this.Property(t => t.medical_plan_id).HasColumnName("medical_plan_id");
            this.Property(t => t.medicine_id).HasColumnName("medicine_id");
            this.Property(t => t.dosage).HasColumnName("dosage");
            this.Property(t => t.usage).HasColumnName("usage");
            this.Property(t => t.note).HasColumnName("note");
            this.Property(t => t.indication).HasColumnName("indication");

            // Relationships
            this.HasOptional(t => t.medical_plan)
                .WithMany(t => t.medical_plan_drug)
                .HasForeignKey(d => d.medical_plan_id);
            this.HasOptional(t => t.medicine)
                .WithMany(t => t.medical_plan_drug)
                .HasForeignKey(d => d.medicine_id);

        }
    }
}
